package com.frontend.api.config;

import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

@Configuration
@EnableCaching
public class RedisConfig extends CachingConfigurerSupport {

    public KeyGenerator keyGenerator() {
        return (target, method, params) -> {
            StringBuilder stringBuffer = new StringBuilder();
            stringBuffer.append(target.getClass().getName());
            stringBuffer.append(method.getName());

            for (Object param : params) {
                stringBuffer.append(Arrays.toString(params));
            }
            return stringBuffer.toString();
        };
    }
}
